﻿using System;
using System.Collections.Generic;
using System.Text;

namespace FileModelNS
{
	/// <summary>
	/// Generic Tree Collection.
	/// </summary>
	/// <typeparam name="T"></typeparam>
	public class Tree<T>
	{
		public List<TreeNode<T>> RootNodes { get { return _RootNodes; } }

		private List<TreeNode<T>> _RootNodes;
		public Tree()
		{
			_RootNodes = new List<TreeNode<T>>();
		}
	}

	/// <summary>
	/// Node class for Tree class.
	/// </summary>
	/// <typeparam name="T"></typeparam>
	public class TreeNode<T>
	{
		public T Value { get; set; }
		public List<TreeNode<T>> ChildNodes
		{
			get
			{
				// Delayed allocation for leaf nodes.
				if ( null == _ChildNodes )
					_ChildNodes = new List<TreeNode<T>>();
				return _ChildNodes;
			}
		}

		private List<TreeNode<T>> _ChildNodes;
		public TreeNode( T value )
		{
			Value = value;
		}
		
	}
}
